package com.kotlin.flong.oop_fp

/**
 * sealed密封类的使用
 */
sealed class LicenseStatus {
    object UnQualified : LicenseStatus()
    object Learning : LicenseStatus()
    class Qualified(val licenseCode: String) : LicenseStatus()
}

class Driver1(var status: LicenseStatus) {
    fun checkArgs(): String {
        return when (status) {
            is LicenseStatus.UnQualified -> "没资格"
            is LicenseStatus.Learning -> "在学"
            is LicenseStatus.Qualified -> "驾驶证编号：${(this.status as LicenseStatus.Qualified).licenseCode}"
        }
    }
}

fun main() {

    val status = LicenseStatus.Qualified(System.currentTimeMillis().toString())
    println(Driver1(status).checkArgs())

}